/**
* All Rights Reserved , Copyright (C) 2021 , 青岛鼎信通讯股份有限公司
*
* MmsResponseService
* 意见反馈回复表
*
* 修改纪录
* 2021-10-29 版本：1.0 zhangqianbo 创建。
* @version 版本：1.0
* @author 作者：zhangqianbo
* 创建日期：2021-10-29
*/
package com.topscomm.mms.service.impl;

import com.topscomm.basic.BasicEntity;
import com.topscomm.cbo.pojo.CboApprovalNodeInsEntity;
import com.topscomm.mms.pojo.MmsResponseEntity;
import com.topscomm.mms.pojo.MmsSuggestionFeedbackEntity;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.SpringUtil;
import com.topscomm.pub.util.StringBufferProxy;
import org.springframework.context.annotation.Scope;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import com.topscomm.mms.service.IMmsResponseService;
import com.topscomm.mms.service.impl.auto.MmsResponseServiceAuto;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(value = "mmsResponseService")
@Scope(value = "singleton")
public class MmsResponseService extends MmsResponseServiceAuto implements IMmsResponseService {
    /**
     * @author
     * @date
     * @description: 将办理意见存入回复表
     * @modify:
     */
    @Transactional
    public void insertApprovalIntoResponse(CboApprovalNodeInsEntity nodeins) throws Exception{
        MmsSuggestionFeedbackService mmsSuggestionFeedbackService = (MmsSuggestionFeedbackService) SpringUtil.getBean("mmsSuggestionFeedbackService");
        String sourceid = ConvertUtil.convertToString(nodeins.getSourceid());
        MmsSuggestionFeedbackEntity mmsSuggestionFeedbackEntity = mmsSuggestionFeedbackService.queryById(sourceid);
        MmsResponseEntity mmsResponseEntity = new MmsResponseEntity();
        mmsResponseEntity.setDealpersonsuggestion(nodeins.getApprovalopinion());
        mmsResponseEntity.setSourcetype(mmsSuggestionFeedbackEntity.getSystem());
        mmsResponseEntity.setSourceid(mmsSuggestionFeedbackEntity.getId());
        this.insert(mmsResponseEntity);
    }
    /**
     * @author
     * @date
     * @description: 将反馈人意见存入回复表
     * @modify:
     */
//    @Transactional
//    public void updateSubmitApprovalOpinion(CboApprovalNodeInsEntity nodeins) throws Exception{
//
//        String sourceid = ConvertUtil.convertToString(nodeins.getSourceid());
//        String sourcetype = ConvertUtil.convertToString(nodeins.getSourcetype());
//
//        MmsSuggestionFeedbackService mmsSuggestionFeedbackService = (MmsSuggestionFeedbackService) SpringUtil.getBean("mmsSuggestionFeedbackService");
//        MmsSuggestionFeedbackEntity mmsSuggestionFeedbackEntity = mmsSuggestionFeedbackService.queryById(sourceid);
//
//        // 根据sourceid和sourcetype查找回复表
//        StringBufferProxy sqlWhere = new StringBufferProxy();
//        sqlWhere.appendSingle("sourceid = {0} and sourcetype = '{1}' ORDER BY CREATEON DESC", sourceid, mmsSuggestionFeedbackEntity.getSystem());
//        MmsResponseEntity mmsResponseEntity = this.queryByWhere(sqlWhere.toString()).get(0);
//        List<MmsResponseEntity> mmsResponseEntities = this.queryByWhere(sqlWhere.toString());
//        mmsResponseEntity.setSubmitpersonsuggestion(nodeins.getApprovalopinion());
//        this.updateEntity(mmsResponseEntity);
//    }

}
